package com.jiazhong.实现接口vs继承类;
//当子类继承父类，就自动拥有了父类的功能
//如果子类需要扩展功能，可以通过实现接口的方式扩展
//可以理解为实现接口是对单继承己志的一种补充
public class Demo01 {
    public static void main(String[] args) {
        LittleMonkey littleMonkey=new LittleMonkey("徐浩源");
        littleMonkey.climbing();
        littleMonkey.swimming();
        littleMonkey.Flying();
    }
}
class Monkey{
    private String name;

    public Monkey(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public void climbing(){
        System.out.println(name+"会爬树");
    }
}
interface FishAbility{
    void swimming();
}
interface BirdAbility{
    void Flying();
}
class LittleMonkey extends Monkey implements FishAbility,BirdAbility{

    public LittleMonkey(String name) {
        super(name);
    }

    @Override
    public void swimming() {
        System.out.println("通过学习，可以像鱼一样游泳");
    }

    @Override
    public void Flying() {
        System.out.println("通过学习，可以像鸟一样飞翔");
    }
}